//
//  ClassForwardLanguageViewController.m
//  Ai
//
//  Created by 杜超男 on 2019/3/13.
//  Copyright © 2019年 杜超男. All rights reserved.
//

#import "ClassForwardLanguageViewController.h"
//#import "ClassForwardLanguageTableViewCell.h"
#import "ClassForwardLanguageTableViewCell.h"
#import "Masonry.h"
@interface ClassForwardLanguageViewController ()<UITableViewDelegate , UITableViewDataSource>
{
    UIView *backView;
    UIView *TipsWindow;
}
@property (weak, nonatomic) IBOutlet UILabel *ClassNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *TimeLabel;
@property (nonatomic , strong)UITableView *tableView;
@end

@implementation ClassForwardLanguageViewController
- (IBAction)BackBtn:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ReportErrorsBtn) name:@"ReportErrors" object:nil];
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 165;
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.tableView registerNib:[UINib nibWithNibName:@"ClassForwardLanguageTableViewCell" bundle:nil] forCellReuseIdentifier:@"ClassForwardLanguageTableViewCell"];
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.tableView];
    self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(110);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(-20);
    }];
    [self Tips];
    
    
    // Do any additional setup after loading the view from its nib.
}
- (void)Tips{
    //提示 周围黑色半透明背景
    backView = [[UIView alloc] init];
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.5;
    [self.view addSubview:backView];
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    backView.hidden = YES;
    //白色提示框
    TipsWindow = [UIView new];
    TipsWindow.backgroundColor = [UIColor whiteColor];
    TipsWindow.alpha = 1;
    TipsWindow.layer.cornerRadius = 10;
    TipsWindow.layer.masksToBounds = YES;
    [self.view addSubview:TipsWindow];
    TipsWindow.hidden = YES;
    [TipsWindow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.right.mas_equalTo(-40);
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(300);
        make.bottom.mas_equalTo(-300);
        
    }];
    //提示文字
    
    UILabel *TipsTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 40, 60, 20)];
    TipsTextLabel.font = [UIFont systemFontOfSize:20];
    TipsTextLabel.text = @"提 示";
    TipsTextLabel.textAlignment = NSTextAlignmentCenter;
    [TipsWindow addSubview:TipsTextLabel];
    UILabel *TipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(17, 80, 300, 60)];
    TipsLabel.text = @"您的反馈对人工智能非常重要，感谢您的支持。";
    TipsLabel.lineBreakMode = NSLineBreakByClipping;
    TipsLabel.font = [UIFont systemFontOfSize:18];
    TipsLabel.numberOfLines = 0;
    TipsLabel.preferredMaxLayoutWidth = 240;
    [TipsWindow addSubview:TipsLabel];
    //确定按钮
    UIButton *SureBtn = [[UIButton alloc] initWithFrame:CGRectMake(120, 190, 115, 30)];
    [SureBtn setTitle:@"确 定" forState:UIControlStateNormal];
    [SureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    SureBtn.layer.cornerRadius = 15;
    SureBtn.layer.masksToBounds = YES;
    //rgba(103/255.0, 194/255.0, 86/255.0, 1)
    [SureBtn setBackgroundColor:[UIColor colorWithRed:103/255.0 green:194/255.0 blue:86/255.0 alpha:1]];
    [SureBtn addTarget:self action:@selector(SureBtn) forControlEvents:UIControlEventTouchUpInside];
    [TipsWindow addSubview:SureBtn];
    
}
- (void)SureBtn{
    backView.hidden = YES;
    TipsWindow.hidden = YES;
}
- (void)ReportErrorsBtn{
    backView.hidden = NO;
    TipsWindow.hidden = NO;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 100;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
//    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    ClassForwardLanguageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ClassForwardLanguageTableViewCell"];
    if (!cell) {
        cell = [[ClassForwardLanguageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ClassForwardLanguageTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 0.01)];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}
-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
